package co.gov.medellin.ssti.sub.service;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.NamingException;

import co.gov.medellin.ssti.sub.common.ConexionFactory;
import co.gov.medellin.ssti.sub.model.dao.DAOFactory;
import co.gov.medellin.ssti.sub.model.dao.IErrorDAO;
import co.gov.medellin.ssti.sub.model.dao.exception.DAOException;

public class ErrorService {
	public int insertError(String strName, String strDescription)
			throws DAOException {
		IErrorDAO errorDAO = null;
		try {
			Connection con = ConexionFactory.getInstance().getConnection();
			errorDAO = DAOFactory.getDAOFactory(DAOFactory.ORACLE).getErrorDAO(
					con);
			return errorDAO.insertError(strName, strDescription);
		} catch (NamingException e) {
			throw new DAOException(e);
		} catch (SQLException e) {
			throw new DAOException(e);
		} finally {
			if (errorDAO != null) {
				if (!errorDAO.isConnClosed()) {
					errorDAO.close();
				}
			}
		}
	}
}
